<?php # Виджет превью акции и новости
class preview_akcion_and_news_widget extends Load_use
{
	function getBlock()
	{
		$html = '';
		$akcii_news = array( 'akcii_item' => array( 'url' => 'akcii', 'title' => 'Акции',   'title2' => 'Все акции',   'color' => '' ),
							 'news_item'  => array( 'url' => 'news',  'title' => 'Новости', 'title2' => 'Все новости', 'color' => ' blue-bg' ) );
		
		foreach( $akcii_news as $templ => $data )
		{
			$html_list = '';
			$this->conn->query('
				SELECT `url`, `title`, `text1`, UNIX_TIMESTAMP( `p`.`date_create` ) AS `date`
					FROM `pages` AS `p`
							WHERE `templ` = "'.$templ.'"
								ORDER BY `p`.`date_create` DESC
									LIMIT 2');
			while( $row = $this->conn->fetch() )
			{
				$html_list .= '	<li>
									<strong class="widget__list__date">'.getDateFormat($row->date).'</strong>
									<div>
										<a href="/'.$data['url'].'/'.$row->url.'" rel="nofollow">'.$row->title.'</a>
									</div>
									<p>'.cropStr( $row->text1, 12 ).' ...</p>
								</li>';
			}
			$html .= '	
						<noindex>
							<div class="widget'.$data['color'].'">
								<div class="widget__title">'.$data['title'].'</div>
								<ul class="widget__list">
									'.$html_list.'
								</ul>
								<a href="/'.$data['url'].'/" class="global-button'.$data['color'].'" rel="nofollow">
									<span class="global-button__inner">'.$data['title2'].'</span>
								</a>
							</div>
						</noindex>';
		}
		return $html;
	}
}